A good answer might be:

val[3] == 25.5


Initializer Lists

You can declare, construct, and initialize the array all in one statement:

int[] data = {23, 38, 14, -3, 0, 14, 9, 103, 0, -56 };

This declares an array of int which is named data. Then it constructs an int array of 10 slots (indexed 0..9). Finally it puts the designated values into the slots. The first value in the initializer list corresponds to index 0, the second value coresponds to index 1, and so on. (So in this example, data[0] gets the 23.)

You do not have to say how many slots the array has. The compiler will count the values in the initializer list and make that many slots. Once an array has been constructed, the number of slots does not change. Initializer lists are usually used only for small arrays.

QUESTION 10:

Write a declaration for an array of double named "dvals" that is initialized to contain 0.0, 0.5, 1.5, 2.0, and 2.5.